Attribute VB_Name = "fileoperation"
 Public Sub DeleteFilesFromFileListBox(ByVal fileListBox As fileListBox)
    On Error GoTo errorhandler
    Dim fileName As String

    If fileListBox.ListCount > 0 Then ' Check if the FileListBox has files
        Dim i As Integer
        For i = 0 To fileListBox.ListCount - 1
            fileName = fileListBox.Path & "\" & fileListBox.List(i) ' Get the full file path

            On Error Resume Next
            Kill fileName ' Attempt to delete the file
            If Err.Number <> 0 Then
                MsgBox "Error deleting file: " & Err.Description, vbExclamation
                Err.Clear
            End If
        Next i

        fileListBox.Refresh ' Refresh the FileListBox to update the display
    Else
       
    End If

    Exit Sub
errorhandler:
    MsgBox "An error occurred: " & Err.Description, vbCritical
End Sub

Public Sub ReloadpacketwinlinkSafely()
    Static Reloaded As Boolean

    If Reloaded Then Exit Sub ' Prevent repeated reloads
    Reloaded = True

    On Error Resume Next
    Unload PACKETWINLINK
    DoEvents          ' Process pending events
    PACKETWINLINK.Show
    Reloaded = False  ' Reset the flag
End Sub


   

